package com.ef.service.impl;

import java.util.List;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;

import com.ef.dao.CorpEventHistoryDao;
import com.ef.domain.Company;
import com.ef.domain.CorpEventHistory;
import com.ef.service.CorpEventHistoryService;

public class CorpEventHistoryServiceImpl extends BaseServiceImpl implements
		CorpEventHistoryService {

	private CorpEventHistoryDao corpEventHistoryDao;

	public List<CorpEventHistory> findByCompany(Company company) {
		DetachedCriteria detachedCriteria = DetachedCriteria
				.forClass(CorpEventHistory.class);
		detachedCriteria.add(Restrictions.eq("company", company));
		detachedCriteria.addOrder(Order.desc("dealTime"));
		return corpEventHistoryDao.findAllByCriteria(detachedCriteria);
	}

	public CorpEventHistory findById(Long id){
		return corpEventHistoryDao.findById(id);
	}
	
	public void saveOrUpdate(CorpEventHistory entity) {
		corpEventHistoryDao.save(entity);
	}

	
	public CorpEventHistoryDao getCorpEventHistoryDao() {
		return corpEventHistoryDao;
	}

	public void setCorpEventHistoryDao(CorpEventHistoryDao corpEventHistoryDao) {
		this.corpEventHistoryDao = corpEventHistoryDao;
	}

}
